/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package server;

import java.rmi.Naming;

/**
 *
 * @author JBP
 */
public class Run {
    private static String OS = System.getProperty("os.name").toLowerCase();
    public static void main(String[] args) {
        try {
            Monitor moni = (Monitor) Naming.lookup("//localhost/Monitor");
            Memoire mem = new Memoire();
            Cpu cp = new Cpu();
            Processus proc = new Processus();
            
            

            //on recupere la memoire libre, utilise et totale
            mem = moni.getMemory();
            System.out.println("Free Memory : "+mem.getFree()+"\nUsed Memory : " +mem.getUsed()+"\nTotal Memory : "+mem.getTotal() );
            
            
            //on recupere dans un string le pourcentage de cpu utilise
            if(OS.indexOf("win") >= 0) 
                ;
            else
                if((OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 )){
                    cp = moni.getCpu();
                    System.out.println("Pourcentage de CPU utilisee : "+cp.getCpu()+"%");
                }
            
            //on recupere dans un string le pourcentage de cpu utilise
            proc = moni.getProcessus();
            System.out.println("Processus en cours : \n");
            System.out.println(proc.getProcess()+"\n");
            
            //Supprimer l'historique
            //moni.supprimerHistorique();
            
        } catch (Exception e) {
            System.out.println("Client exception: " + e.getMessage());
            e.printStackTrace();
        }
        
        
    }
}
